import _ from 'lodash';
import { getDefaultData } from ".";

const isSupportPlaceholder = type => {
  const dftData = getDefaultData(type);

  if (_.isObject(dftData)) {
    return dftData.hasOwnProperty('placeholder');
  }
};

/**
 * 向前兼容组件新增配置
 */
export default function(comType, config) {
  if (isSupportPlaceholder(comType) && !config.hasOwnProperty('placeholder')) {
    config.placeholder = '';
  };

  return config;
}